<?php
	//Default
	$intCommissionShare = 3;
	if($cboCommission == 1){
		//third
		$intCommissionShare = 3;
	}
	
	if($cboCommission == 2){
		//half
		$intCommissionShare = 2;
	}
	//echo "debug txtAuctionSellingFee = ".$txtAuctionSellingFee;
	//echo "debug intCommissionShare = ".$intCommissionShare;
	if($chkCalcCommission){
			if($txtAuctionSellingFee <= 10){
				$txtPayVendor = 0;
				$txtOurCommission = $txtAuctionSellingFee;
				
			}
			
			if(($txtAuctionSellingFee > 10) && ($txtAuctionSellingFee <= 30)){
				$txtPayVendor = $txtAuctionSellingFee - 10;
				$txtOurCommission = 10;
			}
			
			if($txtAuctionSellingFee > 30){
				
				if($intCommissionShare == 3){
					$txtPayVendor = number_format((($txtAuctionSellingFee / 3) * 2), 2, '.', '');
					$txtOurCommission = number_format($txtAuctionSellingFee / 3, 2, '.', '');
				}
				
				if($intCommissionShare == 2){
					$txtPayVendor = number_format(($txtAuctionSellingFee / 2), 2, '.', '');
					$txtOurCommission = number_format($txtAuctionSellingFee / 2, 2, '.', '');
				}
			}
			
		$txtPayUs = $txtOurCommission + $txtCarriagePaid - $txtPayPalFee;
		
		array_push($ActionResults, "Fees have been calculated, please check and save if they are OK.");
		$chkCalcCommission = 0;
		$SCREEN = "EnterAuctionItem";
        return(FALSE);
		
	}

switch ($cboEbayStatus){
	case 0:
		if($txtItemName) {
			$cboEbayStatus = 1;
		}

		if	(($txtQuotedCarriage) || ($txtEbayInsertionFee) || ($txtAuctionStart) || ($txtAuctionDuration) || ($txtAuctionID)){
			$cboEbayStatus = 2;
		}
		break;
		
		
	case 1:
		//ItemName
		 if(!$txtItemName) {
			 array_push($ActionResults, "Please enter Item  Name.");
			 $intFailed++;
		 }else{
			 //$txtItemName = ucwords(strtolower($txtItemName)); 
		 }
	
		  if(!$txtDescription) {
			 array_push($ActionResults, "Please enter Description.");
			 $intFailed++;
		 }else{
			 //$txtDescription = ucfirst(strtolower($txtDescription)); 
		 }
	
		//UploadedPhoto1
		 if($cboUploadedPhoto1 == 1) {
			 if(!$txtUploadedPhoto1) {
				 array_push($ActionResults, "Your document was not attached.");
				 return(FALSE);
			 }
		 }
	
	
		 if(!$cboEbayStatus) {
			 array_push($ActionResults, "Please enter auction status.");
			 $intFailed++;
		 }
	break;
	
		case 2:
		 
			//  STATUS 2 - LOADED
			//QuotedCarriage   
			
			if((!$txtWeight) || ($txtWeight== 0)) {
				 array_push($ActionResults, "Please enter weight.");
				 $intFailed++;
			 }else{
				 $txtWeight = ucwords(strtolower($txtWeight)); 
			 }
			 
			 
			 if(!$txtQuotedCarriage) {
				 array_push($ActionResults, "Please enter Quoted Carriage.");
				 $intFailed++;
			 }else{
				 $txtQuotedCarriage = ucwords(strtolower($txtQuotedCarriage)); 
			 }
		
			//EbayInsertionFee
			 if((!$txtEbayInsertionFee)||($txtEbayInsertionFee == 0)) {
				 array_push($ActionResults, "Please enter Ebay Insertion Fee.");
				 $intFailed++;
			 }else{
				 $txtEbayInsertionFee = ucwords(strtolower($txtEbayInsertionFee)); 
			 }
		
			 if(!$txtAuctionStart) {
				 array_push($ActionResults, "Please enter Auction Start.");
				 $intFailed++;
			 }else{
			 }
		
			 if(!$txtAuctionDuration) {
				 array_push($ActionResults, "Please enter auction duration.");
				 $intFailed++;
			 }else{
				 //$txtAuctionDuration = ucfirst(strtolower($txtAuctionDuration)); 
			 }
		
			//AuctionID
			if(!$txtAuctionID) {
				 array_push($ActionResults, "Please enter auction number.");
				 $intFailed++;
			 }else{
				 //$txtAuctionID = ucwords(strtolower($txtAuctionID)); 
			 }
	break;
	
	case 3:
		//AuctionSellingFee
		 if((!$txtAuctionSellingFee)||($txtAuctionSellingFee == 0)) {
			 array_push($ActionResults, "Please enter auction sale price.");
			 $intFailed++;
		 }else{
			 $txtAuctionSellingFee = ucwords(strtolower($txtAuctionSellingFee)); 
		 }
	break;
	
	case 4:
		//PayPalFeePayVendor 
		
		if((!$txtDatePaid) || ($txtDatePaid == 0))  {
			 array_push($ActionResults, "Please enter  the date the item was paid for.");
			 $intFailed++;
		 }
		
		if(( (!$txtPayVendor) || ($txtPayVendor == 0) ) && ($txtAuctionSellingFee != $txtOurCommission) ) {
			 array_push($ActionResults, "Please enter  the amount we have to pay vendor.");
			 $intFailed++;
		 }
		
		if((!$txtOurCommission) ||($txtOurCommission == 0)) {
			 array_push($ActionResults, "Please enter  our commission.");
			 $intFailed++;
		 }
		
		//if((!$txtCarriagePaid) ||($txtCarriagePaid == 0)) {
			 //array_push($ActionResults, "Please enter  carriage paid.");
			 //$intFailed++;
		 //}
		
		 if(!$txtPayPalTXN) {
			 array_push($ActionResults, "Please enter  PayPal TXN ID.");
			 $intFailed++;
		 }
		 
		 if((strtolower($txtPayPalTXN) == "cheque") || (strtolower($txtPayPalTXN) == "cash")) { 
		 }else{

			 if((!$txtPayPalFee)||($txtPayPalFee == 0)) {
				 array_push($ActionResults, "Please enter  PayPal fee.");
				 $intFailed++;
			 }else{
				 $txtPayPalFee = ucwords(strtolower($txtPayPalFee)); 
			 }	  
			 
		 }
		  if(!$cboTitle) {
			 array_push($ActionResults, "Please enter Purchaser Title.");
			 $intFailed++;
		 }else{
			 //$cboTitle = ucfirst(strtolower($cboTitle)); 
		 }
	
		//FirstName
		 if(!$txtFirstName) {
			 array_push($ActionResults, "Please enter Purchaser First Name.");
			 $intFailed++;
		 }else{
			 $txtFirstName = ucwords(strtolower($txtFirstName)); 
		 }
	
		//Surname
		 if(!$txtSurname) {
			 array_push($ActionResults, "Please enter  PurchaserSurname.");
			 $intFailed++;
		 }else{
			 $txtSurname = ucwords(strtolower($txtSurname)); 
		 }
	
		//Address1
		 if(!$txtAddress1) {
			 array_push($ActionResults, "Please enter Purchaser Address1.");
			 $intFailed++;
		 }else{
			 $txtAddress1 = ucwords(strtolower($txtAddress1)); 
		 }
	
		//Town
		 if(!$txtTown) {
			 array_push($ActionResults, "Please enter Purchaser Town.");
			 $intFailed++;
		 }else{
			 $txtTown = ucwords(strtolower($txtTown)); 
		 }
	
		//County
		 //if(!$txtCounty) {
			// array_push($ActionResults, "Please enter Purchaser County.");
			 //$intFailed++;
		// }else{
			 $txtCounty = ucwords(strtolower($txtCounty)); 
		// }
	
		//PostalCode
		 if(!$txtPostalCode) {
			 array_push($ActionResults, "Please enter Purchaser Postal Code.");
			 $intFailed++;
		 }else{
			 $txtPostalCode = strtoupper($txtPostalCode); 
		 }
	
		  if(!$cboCountry) {
			 array_push($ActionResults, "Please enter Purchaser Country.");
			 $intFailed++;
		 }else{
			 //$cboCountry = ucfirst(strtolower($cboCountry)); 
		 }
	
		//Phone
		/*
		 if(!$txtPhone) {
			 array_push($ActionResults, "Please enter Purchaser Phone.");
			 $intFailed++;
		 }else{
			 $txtPhone = ucwords(strtolower($txtPhone)); 
		 }
		*/
		  if(!$txtChequeSent) {
			 array_push($ActionResults, "Please enter Cheque Sent (date).");
			 $intFailed++;
		 }else{
		 }
		 
		 break;
	}

     if($intFailed > 0){
	 	$SCREEN = "EnterAuctionItem";
         return(FALSE);
     }

     if ($intAuctionItemID){
        $strSQL = "Update tblAuctionItem
                     SET   tblAuctionItem.Vendor =  '$txtVendor'
                         , tblAuctionItem.ItemName =  '$txtItemName' 
						 , tblAuctionItem.DespatchToUK =  '$chkDespatchToUK' 
						 , tblAuctionItem.DespatchToEurope =  '$chkDespatchToEurope'
						 , tblAuctionItem.DespatchToUSA =  '$chkDespatchToUSA'
						 , tblAuctionItem.DespatchToAustralia =  '$chkDespatchToAustralia'
                         , tblAuctionItem.Description =  '$txtDescription' 
						 , tblAuctionItem.Commission = '$cboCommission'
						 , tblAuctionItem.Disclaimer = '$cboDisclaimer'
                         , tblAuctionItem.Condition =  '$cboCondition'
                         , tblAuctionItem.ReservePrice =  '$txtReservePrice'
                         , tblAuctionItem.ReserveFee =  '$txtReserveFee'
                         , tblAuctionItem.CostPrice =  '$txtCostPrice'
                         , tblAuctionItem.VAT =  '$chkVAT'
                         , tblAuctionItem.VatRate =  '$cboVatRate'
                         , tblAuctionItem.VATNumber =  '$txtVATNumber'
                         , tblAuctionItem.BackgroundHistory =  '$txtBackgroundHistory'
                         , tblAuctionItem.UnderWarranty =  '$chkUnderWarranty'
                         , tblAuctionItem.Manual =  '$chkManual'
                         , tblAuctionItem.Height =  '$txtHeight'
                         , tblAuctionItem.Width =  '$txtWidth'
                         , tblAuctionItem.Length =  '$txtLength'
                         , tblAuctionItem.Weight =  '$txtWeight'
                         , tblAuctionItem.Quantity =  '$txtQuantity'
                         , tblAuctionItem.Photos =  '$chkPhotos'
                         , tblAuctionItem.DirectDespatch =  '$chkDirectDespatch'
                         , tblAuctionItem.EbayStatus =  '$cboEbayStatus'
                         , tblAuctionItem.QuotedCarriage =  '$txtQuotedCarriage'
                         , tblAuctionItem.EbayInsertionFee =  '$txtEbayInsertionFee'
                         , tblAuctionItem.AuctionStart =  '".ReformatToMySqlDate($txtAuctionStart)."'
                         , tblAuctionItem.AuctionDuration =  '$txtAuctionDuration'
                         , tblAuctionItem.AuctionID =  '$txtAuctionID'
                         , tblAuctionItem.AuctionSellingFee =  '$txtAuctionSellingFee'
                         , tblAuctionItem.ReceivedPayment =  '$chkReceivedPayment'
                         , tblAuctionItem.PayPalTXN =  '$txtPayPalTXN'
						 , tblAuctionItem.PayPalFee =  '$txtPayPalFee'
						 , tblAuctionItem.CarriagePaid =  '$txtCarriagePaid'
						 , tblAuctionItem.OurCommission =  '$txtOurCommission'
						 , tblAuctionItem.PayUs =  '$txtPayUs'
						 , tblAuctionItem.PayVendor =  '$txtPayVendor'
						 , tblAuctionItem.DatePaid =  '".ReformatToMySqlDate($txtDatePaid)."'
                         , tblAuctionItem.PurchaserEbayID =  '$txtPurchaserEbayID'
                         , tblAuctionItem.Title =  '$cboTitle'
                         , tblAuctionItem.CompanyName =  '$txtCompanyName'
                         , tblAuctionItem.FirstName =  '$txtFirstName'
                         , tblAuctionItem.Surname =  '$txtSurname'
                         , tblAuctionItem.Address1 =  '$txtAddress1'
                         , tblAuctionItem.Address2 =  '$txtAddress2'
                         , tblAuctionItem.Town =  '$txtTown'
                         , tblAuctionItem.County =  '$txtCounty'
                         , tblAuctionItem.PostalCode =  '$txtPostalCode'
                         , tblAuctionItem.Country =  '$cboCountry'
                         , tblAuctionItem.Phone =  '$txtPhone'
                         , tblAuctionItem.Mobile =  '$txtMobile'
                         , tblAuctionItem.Fax =  '$txtFax'
                         , tblAuctionItem.Email =  '$txtEmail'
                         , tblAuctionItem.Despatched =  '$chkDespatched'
                         , tblAuctionItem.DespatchDate =  '".ReformatToMySqlDate($txtDespatchDate)."'
                         , tblAuctionItem.Courier =  '$cboCourier'
                         , tblAuctionItem.ConsignmentNumber =  '$txtConsignmentNumber'
                         , tblAuctionItem.ChequeSent =  '".ReformatToMySqlDate($txtChequeSent)."'"; 
        $strJoin = " WHERE ";
        $strSQL .= $strJoin."tblAuctionItem.ID =  '$intAuctionItemID'";
        $strMessage = " Updated";
    }Else{

        $strSQL = "INSERT INTO tblAuctionItem
                     (     tblAuctionItem.Vendor
                         , tblAuctionItem.ItemName
						 , tblAuctionItem.Commission
						 , tblAuctionItem.DespatchToUK 
						 , tblAuctionItem.DespatchToEurope 
						 , tblAuctionItem.DespatchToUSA 
						 , tblAuctionItem.DespatchToAustralia 
                         , tblAuctionItem.Description
						 , tblAuctionItem.Disclaimer
                         , tblAuctionItem.Condition
                         , tblAuctionItem.ReservePrice
                         , tblAuctionItem.ReserveFee
                         , tblAuctionItem.CostPrice
                         , tblAuctionItem.VAT
                         , tblAuctionItem.VatRate
                         , tblAuctionItem.VATNumber
                         , tblAuctionItem.BackgroundHistory
                         , tblAuctionItem.UnderWarranty
                         , tblAuctionItem.Manual
                         , tblAuctionItem.Height
                         , tblAuctionItem.Width
                         , tblAuctionItem.Length
                         , tblAuctionItem.Weight
                         , tblAuctionItem.Quantity
                         , tblAuctionItem.Photos
                         , tblAuctionItem.DirectDespatch
                         , tblAuctionItem.EbayStatus
                         , tblAuctionItem.QuotedCarriage
                         , tblAuctionItem.EbayInsertionFee
                         , tblAuctionItem.AuctionStart
                         , tblAuctionItem.AuctionDuration
                         , tblAuctionItem.AuctionID
                         , tblAuctionItem.AuctionSellingFee
                         , tblAuctionItem.ReceivedPayment
                         , tblAuctionItem.PayPalTXN
						 , tblAuctionItem.PayPalFee
						 , tblAuctionItem.CarriagePaid
						 , tblAuctionItem.OurCommission
						 , tblAuctionItem.PayUs 
						 , tblAuctionItem.PayVendor 
						 , tblAuctionItem.DatePaid 
                         , tblAuctionItem.PurchaserEbayID
                         , tblAuctionItem.Title
                         , tblAuctionItem.CompanyName
                         , tblAuctionItem.FirstName
                         , tblAuctionItem.Surname
                         , tblAuctionItem.Address1
                         , tblAuctionItem.Address2
                         , tblAuctionItem.Town
                         , tblAuctionItem.County
                         , tblAuctionItem.PostalCode
                         , tblAuctionItem.Country
                         , tblAuctionItem.Phone
                         , tblAuctionItem.Mobile
                         , tblAuctionItem.Fax
                         , tblAuctionItem.Email
                         , tblAuctionItem.Despatched
                         , tblAuctionItem.DespatchDate
                         , tblAuctionItem.Courier
                         , tblAuctionItem.ConsignmentNumber
                         , tblAuctionItem.ChequeSent
                     )Values( '$txtVendor'
                         , '$txtItemName'
 						 , '$cboCommission'	     
						 , '$chkDespatchToUK' 
						 , '$chkDespatchToEurope'
						 , '$chkDespatchToUSA'
						 , '$chkDespatchToAustralia'
                         , '$txtDescription'	 
						 , '$cboDisclaimer'
                         , '$cboCondition'
                         , '$txtReservePrice'
                         , '$txtReserveFee'
                         , '$txtCostPrice'
                         , '$chkVAT'
                         , '$cboVatRate'
                         , '$txtVATNumber'
                         , '$txtBackgroundHistory'
                         , '$chkUnderWarranty'
                         , '$chkManual'
                         , '$txtHeight'
                         , '$txtWidth'
                         , '$txtLength'
                         , '$txtWeight'
                         , '$txtQuantity'
                         , '$chkPhotos'
                         , '$chkDirectDespatch'
                         , '$cboEbayStatus'
                         , '$txtQuotedCarriage'
                         , '$txtEbayInsertionFee'
                         , '".ReformatToMySqlDate($txtAuctionStart)."'
                         , '$txtAuctionDuration'
                         , '$txtAuctionID'
                         , '$txtAuctionSellingFee'
                         , '$chkReceivedPayment'
						 , '$txtPayPalTXN'
                         , '$txtPayPalFee'
						 , '$txtCarriagePaid'
						 , '$txtOurCommission'
						 , '$txtPayUs'
						 , '$txtPayVendor'
						 , '".ReformatToMySqlDate($txtDatePaid)."'
                         , '$txtPurchaserEbayID'
                         , '$cboTitle'
                         , '$txtCompanyName'
                         , '$txtFirstName'
                         , '$txtSurname'
                         , '$txtAddress1'
                         , '$txtAddress2'
                         , '$txtTown'
                         , '$txtCounty'
                         , '$txtPostalCode'
                         , '$cboCountry'
                         , '$txtPhone'
                         , '$txtMobile'
                         , '$txtFax'
                         , '$txtEmail'
                         , '$chkDespatched'
                         , '".ReformatToMySqlDate($txtDespatchDate)."'
                         , '$cboCourier'
                         , '$txtConsignmentNumber'
                         , '".ReformatToMySqlDate($txtChequeSent)."'
                       )";
        $strMessage = "added";
    }
    $strSQL .= ";";
	//echo $strSQL;
         if (!include (MODULE . "/action/actMySqlResults")){
             array_push($ActionResults,"Failed To Add Auction Item To Database");
             return(false);
         }else{
            // unset($intAuctionItemID);
         }
		 
 if (!$intAuctionItemID){
	 $intAuctionItemID = mysql_insert_id();
 }

 if($cboUploadedPhoto1 == 1) {

         if(!is_uploaded_file($txtUploadedPhoto1)){
             array_push($ActionResults,"Your Uploaded Photo1 was not attached.");
             return(false);
         }

         if(!copy($txtUploadedPhoto1,"./images/auction/item".$intAuctionItemID."Photo1.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo1 to directory");
             return(false);
         } 
		 
		 if(!copy($txtUploadedPhoto1,"./images/auction/thumbz/item".$intAuctionItemID."Photo1.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo1 to directory");
             return(false);
         }	  
		 
		 if(CreateThumbNail("./images/auction/","item".$intAuctionItemID."Photo1.jpg",300,"",300)){
			array_push($ActionResults,"Resize of photo1 picture failed");
			return(FALSE);
		 }
		 
		 if(CreateThumbNail("./images/auction/thumbz/","item".$intAuctionItemID."Photo1.jpg",100,"",100)){
			array_push($ActionResults,"Resize of thumbnail picture failed");
			return(FALSE);
		 }
		 
		 $strSQL = "Update tblAuctionItem
	                 SET UploadedPhoto1 = 'item".$intAuctionItemID."Photo1.jpg'
	                 WHERE
	                 ID = ".$intAuctionItemID;
	     include (MODULE . "/action/actMySqlResults");
	     unlink($txtUploadedPhoto1);

	}  	 
	
	 if($cboUploadedPhoto2 == 1) {

         if(!is_uploaded_file($txtUploadedPhoto2)){
             array_push($ActionResults,"Your Uploaded Photo2 was not attached.");
             return(false);
         }

         if(!copy($txtUploadedPhoto2,"./images/auction/item".$intAuctionItemID."Photo2.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo2 to directory");
             return(false);
         } 
		 
		 if(!copy($txtUploadedPhoto2,"./images/auction/thumbz/item".$intAuctionItemID."Photo2.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo2 to directory");
             return(false);
         }	  
		 
		 if(CreateThumbNail("./images/auction/","item".$intAuctionItemID."Photo2.jpg",300,"",300)){
			array_push($ActionResults,"Resize of thumbnail picture failed");
			return(FALSE);
		 }
		 
		 if(CreateThumbNail("./images/auction/thumbz/","item".$intAuctionItemID."Photo2.jpg",100,"",100)){
			array_push($ActionResults,"Resize of thumbnail picture failed");
			return(FALSE);
		 }
		 
		  
		 $strSQL = "Update tblAuctionItem
	                 SET UploadedPhoto2 = 'item".$intAuctionItemID."Photo2.jpg'
	                 WHERE
	                 ID = ".$intAuctionItemID;
	     include (MODULE . "/action/actMySqlResults");
	     unlink($txtUploadedPhoto2);

	}  
	
	
	 if($cboUploadedPhoto3 == 1) {

         if(!is_uploaded_file($txtUploadedPhoto3)){
             array_push($ActionResults,"Your Uploaded Photo3 was not attached.");
             return(false);
         }

         if(!copy($txtUploadedPhoto3,"./images/auction/item".$intAuctionItemID."Photo3.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo3 to directory");
             return(false);
         } 
		 
		 if(!copy($txtUploadedPhoto3,"./images/auction/thumbz/item".$intAuctionItemID."Photo3.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo3 to directory");
             return(false);
         }	  
		 
		 if(CreateThumbNail("./images/auction/","item".$intAuctionItemID."Photo3.jpg",300,"",300)){
			array_push($ActionResults,"Resize of 3 picture failed");
			return(FALSE);
		 }
		 
		 if(CreateThumbNail("./images/auction/thumbz/","item".$intAuctionItemID."Photo3.jpg",100,"",100)){
			array_push($ActionResults,"Resize of thumbnail picture failed");
			return(FALSE);
		 }
		 
		  
		 $strSQL = "Update tblAuctionItem
	                 SET UploadedPhoto3 = 'item".$intAuctionItemID."Photo3.jpg'
	                 WHERE
	                 ID = ".$intAuctionItemID;
	     include (MODULE . "/action/actMySqlResults");
	     unlink($txtUploadedPhoto3);

	}  
	
	
	 if($cboUploadedPhoto4 == 1) {

         if(!is_uploaded_file($txtUploadedPhoto4)){
             array_push($ActionResults,"Your Uploaded Photo4 was not attached.");
             return(false);
         }

         if(!copy($txtUploadedPhoto4,"./images/auction/item".$intAuctionItemID."Photo4.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo4 to directory");
             return(false);
         } 
		 
		 if(!copy($txtUploadedPhoto4,"./images/auction/thumbz/item".$intAuctionItemID."Photo4.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo4 to directory");
             return(false);
         }	  
		 
		 if(CreateThumbNail("./images/auction/","item".$intAuctionItemID."Photo4.jpg",300,"",300)){
			array_push($ActionResults,"Resize of 4 picture failed");
			return(FALSE);
		 }
		 
		 if(CreateThumbNail("./images/auction/thumbz/","item".$intAuctionItemID."Photo4.jpg",100,"",100)){
			array_push($ActionResults,"Resize of thumbnail picture failed");
			return(FALSE);
		 }
		 
		  
		 $strSQL = "Update tblAuctionItem
	                 SET UploadedPhoto4 = 'item".$intAuctionItemID."Photo4.jpg'
	                 WHERE
	                 ID = ".$intAuctionItemID;
	     include (MODULE . "/action/actMySqlResults");
	     unlink($txtUploadedPhoto4);

	}  
	
	
	 if($cboUploadedPhoto5 == 1) {

         if(!is_uploaded_file($txtUploadedPhoto5)){
             array_push($ActionResults,"Your Uploaded Photo5 was not attached.");
             return(false);
         }

         if(!copy($txtUploadedPhoto5,"./images/auction/item".$intAuctionItemID."Photo5.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo5 to directory");
             return(false);
         } 
		 
		 if(!copy($txtUploadedPhoto5,"./images/auction/thumbz/item".$intAuctionItemID."Photo5.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo5 to directory");
             return(false);
         }	  
		 
		 if(CreateThumbNail("./images/auction/","item".$intAuctionItemID."Photo5.jpg",300,"",300)){
			array_push($ActionResults,"Resize of thumbnail picture failed");
			return(FALSE);
		 }
		 
		 if(CreateThumbNail("./images/auction/thumbz/","item".$intAuctionItemID."Photo5.jpg",100,"",100)){
			array_push($ActionResults,"Resize of 6 picture failed");
			return(FALSE);
		 }
		 
		  
		 $strSQL = "Update tblAuctionItem
	                 SET UploadedPhoto5 = 'item".$intAuctionItemID."Photo5.jpg'
	                 WHERE
	                 ID = ".$intAuctionItemID;
	     include (MODULE . "/action/actMySqlResults");
	     unlink($txtUploadedPhoto5);

	}  
	
	
	 if($cboUploadedPhoto6 == 1) {

         if(!is_uploaded_file($txtUploadedPhoto6)){
             array_push($ActionResults,"Your Uploaded Photo6 was not attached.");
             return(false);
         }

         if(!copy($txtUploadedPhoto6,"./images/auction/item".$intAuctionItemID."Photo6.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo6 to directory");
             return(false);
         } 
		 
		 if(!copy($txtUploadedPhoto6,"./images/auction/thumbz/item".$intAuctionItemID."Photo6.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo6 to directory");
             return(false);
         }	  
		 
		 if(CreateThumbNail("./images/auction/","item".$intAuctionItemID."Photo6.jpg",300,"",300)){
			array_push($ActionResults,"Resize of 6 picture failed");
			return(FALSE);
		 }
		 
		 if(CreateThumbNail("./images/auction/thumbz/","item".$intAuctionItemID."Photo6.jpg",100,"",100)){
			array_push($ActionResults,"Resize of thumbnail picture failed");
			return(FALSE);
		 }
		 
		  
		 $strSQL = "Update tblAuctionItem
	                 SET UploadedPhoto6 = 'item".$intAuctionItemID."Photo6.jpg'
	                 WHERE
	                 ID = ".$intAuctionItemID;
	     include (MODULE . "/action/actMySqlResults");
	     unlink($txtUploadedPhoto6);

	}  
	
	
	 if($cboUploadedPhoto7 == 1) {

         if(!is_uploaded_file($txtUploadedPhoto7)){
             array_push($ActionResults,"Your Uploaded Photo7 was not attached.");
             return(false);
         }

         if(!copy($txtUploadedPhoto7,"./images/auction/item".$intAuctionItemID."Photo7.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo7 to directory");
             return(false);
         } 
		 
		 if(!copy($txtUploadedPhoto7,"./images/auction/thumbz/item".$intAuctionItemID."Photo7.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo7 to directory");
             return(false);
         }	
		 
		 if(CreateThumbNail("./images/auction/","item".$intAuctionItemID."Photo7.jpg",300,"",300)){
			array_push($ActionResults,"Resize of 7 picture failed");
			return(FALSE);
		 }  
		 
		 if(CreateThumbNail("./images/auction/thumbz/","item".$intAuctionItemID."Photo7.jpg",100,"",100)){
			array_push($ActionResults,"Resize of thumbnail picture failed");
			return(FALSE);
		 }
		 
		  
		 $strSQL = "Update tblAuctionItem
	                 SET UploadedPhoto7 = 'item".$intAuctionItemID."Photo7.jpg'
	                 WHERE
	                 ID = ".$intAuctionItemID;
	     include (MODULE . "/action/actMySqlResults");
	     unlink($txtUploadedPhoto7);

	}  
	
	 if($cboUploadedPhoto8 == 1) {

         if(!is_uploaded_file($txtUploadedPhoto8)){
             array_push($ActionResults,"Your Uploaded Photo8 was not attached.");
             return(false);
         }

         if(!copy($txtUploadedPhoto8,"./images/auction/item".$intAuctionItemID."Photo8.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo8 to directory");
             return(false);
         } 
		 
		 if(!copy($txtUploadedPhoto8,"./images/auction/thumbz/item".$intAuctionItemID."Photo8.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo8 to directory");
             return(false);
         }	  
		 
		 if(CreateThumbNail("./images/auction/","item".$intAuctionItemID."Photo8.jpg",300,"",300)){
			array_push($ActionResults,"Resize of 7 picture failed");
			return(FALSE);
		 }
		 
		 if(CreateThumbNail("./images/auction/thumbz/","item".$intAuctionItemID."Photo8.jpg",100,"",100)){
			array_push($ActionResults,"Resize of thumbnail picture failed");
			return(FALSE);
		 }
		 
		  
		 $strSQL = "Update tblAuctionItem
	                 SET UploadedPhoto8 = 'item".$intAuctionItemID."Photo8.jpg'
	                 WHERE
	                 ID = ".$intAuctionItemID;
	     include (MODULE . "/action/actMySqlResults");
	     unlink($txtUploadedPhoto8);

	}  
	
	
	 if($cboUploadedPhoto9 == 1) {

         if(!is_uploaded_file($txtUploadedPhoto9)){
             array_push($ActionResults,"Your Uploaded Photo9 was not attached.");
             return(false);
         }

         if(!copy($txtUploadedPhoto9,"./images/auction/item".$intAuctionItemID."Photo9.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo9 to directory");
             return(false);
         } 
		 
		 if(!copy($txtUploadedPhoto9,"./images/auction/thumbz/item".$intAuctionItemID."Photo9.jpg")){
             array_push($ActionResults,"Failed To copy Uploaded Photo9 to directory");
             return(false);
         }	 
		 
		 if(CreateThumbNail("./images/auction/","item".$intAuctionItemID."Photo9.jpg",300,"",300)){
			array_push($ActionResults,"Resize of thumbnail picture failed");
			return(FALSE);
		 } 
		 
		 if(CreateThumbNail("./images/auction/thumbz/","item".$intAuctionItemID."Photo9.jpg",100,"",100)){
			array_push($ActionResults,"Resize of thumbnail picture failed");
			return(FALSE);
		 }
		 
		  
		 $strSQL = "Update tblAuctionItem
	                 SET UploadedPhoto9 = 'item".$intAuctionItemID."Photo9.jpg'
	                 WHERE
	                 ID = ".$intAuctionItemID;
	     include (MODULE . "/action/actMySqlResults");
	     unlink($txtUploadedPhoto9);

	}  
	
?>
